package o;

import com.huawei.appmarket.support.storage.referrer.AppReferrerRecord;
import java.util.List;

public class eun {
    private static eun ˋ = null;
    private static final Object ˏ = new byte[0];
    private cfu ॱ = euc.ˊ().ʽ(AppReferrerRecord.TABLE_NAME);

    private eun() {
    }

    public static eun ˏ() {
        eun o_eun;
        synchronized (ˏ) {
            if (ˋ == null) {
                ˋ = new eun();
            }
            o_eun = ˋ;
        }
        return o_eun;
    }

    public List<AppReferrerRecord> ˊ(String str, String str2) {
        if (str == null) {
            return null;
        }
        String str3;
        String[] strArr;
        ˊ();
        if (str2 == null) {
            str3 = "pkgName_=?";
            strArr = new String[]{str};
        } else {
            str3 = "pkgName_=? and mediaPkg_=?";
            strArr = new String[]{str, str2};
        }
        return this.ॱ.ˋ(AppReferrerRecord.class, str3, strArr, null, null);
    }

    public long ˎ(AppReferrerRecord appReferrerRecord) {
        if (this.ॱ.ˋ(AppReferrerRecord.class, "pkgName_=?", new String[]{appReferrerRecord.ˊ()}, null, null).isEmpty()) {
            return this.ॱ.ˎ((cfr) appReferrerRecord);
        }
        return (long) this.ॱ.ॱ(appReferrerRecord, "pkgName_=?", new String[]{appReferrerRecord.ˊ()});
    }

    private int ˊ() {
        String[] strArr = new String[]{String.valueOf((System.currentTimeMillis() / 1000) - 7776000)};
        return this.ॱ.ˋ("installTime_<?", strArr);
    }

    public void ˏ(String str) {
        if (str == null) {
            Logger.e("AppReferrerDAO", "removeAppReferrer: package name is null!");
            return;
        }
        this.ॱ.ˋ("pkgName_=?", new String[]{str});
    }
}
